import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 获取角色数据
export function listData(queryParams) {
    const data = {
      ascriptionId: store.state.userInfo.ascriptionId,
      currentPage: queryParams.pageNum,
      pagesize: queryParams.pageSize
    }
    return request({
      url: '/getRoleList',
      method: 'post',
      data: data
    })
}

// 新增
export function addData(val) {
  const data = {
    projectContent:{
      ascriptionId: store.state.userInfo.ascriptionId,
      roleName: val.roleName, //角色名称
      jurisdiction: val.jurisdiction, //权限文本列表
      menuIds: val.menuIds, //权限列表
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/addRole',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getRoleData',
    method: 'post',
    data: data
  })
}

// 修改
export function updateData(val) {
  const data = {
    projectContent:{
      theid: val.theid, //id
      roleName: val.roleName, //角色名称
      jurisdiction: val.jurisdiction, //权限文本列表
      menuIds: val.menuIds, //权限列表
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/updateRole',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delRole',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delMultipleRole',
    method: 'post',
    data: data
  })
}
